# download_font.py
import requests
import os


def download_font():
    # 创建目录
    os.makedirs("../static/fonts", exist_ok=True)

    # 实习僧可能的字体URL
    font_urls = [
        "https://www.shixiseng.com/interns/iconfonts/file",
        "https://static.shixiseng.com/interns/iconfonts/file",
        "https://www.shixiseng.com/interns/iconfonts/iconfont.woff",
        "https://static.shixiseng.com/interns/iconfonts/iconfont.woff"
    ]

    for url in font_urls:
        try:
            print(f"尝试下载: {url}")
            response = requests.get(url)
            if response.status_code == 200:
                # 保存为 file
                with open("../static/fonts/file", "wb") as f:
                    f.write(response.content)
                print("✅ 字体文件下载成功！")
                return True
        except Exception as e:
            print(f"下载失败: {e}")

    print("❌ 所有URL都下载失败")
    return False


if __name__ == "__main__":
    download_font()